home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / vbprnt20.zip / VB3 / VBPRINT.FRM < prev    next >
Text File  |  1996-05-31  |  10KB  |  315 lines

  1. VERSION 2.00
  2. Begin Form frmMain 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "VBPrint Functions"
  5.    ClientHeight    =   4215
  6.    ClientLeft      =   1665
  7.    ClientTop       =   3090
  8.    ClientWidth     =   6195
  9.    Height          =   4650
  10.    Left            =   1605
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4215
  13.    ScaleWidth      =   6195
  14.    Top             =   2715
  15.    Width           =   6315
  16.    Begin Frame Frame1 
  17.       BackColor       =   &H00C0C0C0&
  18.       Caption         =   "Printer Features"
  19.       Height          =   1695
  20.       Left            =   0
  21.       TabIndex        =   11
  22.       Top             =   2460
  23.       Width           =   6180
  24.       Begin ListBox lstRes 
  25.          Height          =   615
  26.          Left            =   5025
  27.          TabIndex        =   17
  28.          Top             =   420
  29.          Width           =   975
  30.       End
  31.       Begin ListBox lstBins 
  32.          Height          =   615
  33.          Left            =   3135
  34.          TabIndex        =   15
  35.          Top             =   420
  36.          Width           =   1785
  37.       End
  38.       Begin ListBox lstPapers 
  39.          Height          =   1200
  40.          Left            =   135
  41.          TabIndex        =   12
  42.          Top             =   420
  43.          Width           =   2940
  44.       End
  45.       Begin Label Label1 
  46.          AutoSize        =   -1  'True
  47.          BackStyle       =   0  'Transparent
  48.          Caption         =   "Resolutions"
  49.          Height          =   195
  50.          Index           =   5
  51.          Left            =   5025
  52.          TabIndex        =   16
  53.          Top             =   195
  54.          Width           =   1005
  55.       End
  56.       Begin Label Label1 
  57.          AutoSize        =   -1  'True
  58.          BackStyle       =   0  'Transparent
  59.          Caption         =   "Paper bins"
  60.          Height          =   195
  61.          Index           =   4
  62.          Left            =   3120
  63.          TabIndex        =   14
  64.          Top             =   195
  65.          Width           =   915
  66.       End
  67.       Begin Label Label1 
  68.          AutoSize        =   -1  'True
  69.          BackStyle       =   0  'Transparent
  70.          Caption         =   "Paper types"
  71.          Height          =   195
  72.          Index           =   3
  73.          Left            =   135
  74.          TabIndex        =   13
  75.          Top             =   195
  76.          Width           =   1020
  77.       End
  78.    End
  79.    Begin CheckBox chkDefault 
  80.       BackColor       =   &H00C0C0C0&
  81.       Caption         =   "Use Windows defaults in dialog"
  82.       Height          =   195
  83.       Left            =   75
  84.       TabIndex        =   5
  85.       Top             =   2175
  86.       Width           =   3270
  87.    End
  88.    Begin CheckBox chkPerm 
  89.       BackColor       =   &H00C0C0C0&
  90.       Caption         =   "Make changes permanent"
  91.       Height          =   195
  92.       Left            =   75
  93.       TabIndex        =   4
  94.       Top             =   1905
  95.       Width           =   2745
  96.    End
  97.    Begin Timer Timer1 
  98.       Interval        =   1000
  99.       Left            =   6015
  100.       Top             =   9670
  101.    End
  102.    Begin CommandButton cmdBtn 
  103.       Caption         =   "E&xit"
  104.       Height          =   330
  105.       Index           =   2
  106.       Left            =   4800
  107.       TabIndex        =   3
  108.       Top             =   1560
  109.       Width           =   1300
  110.    End
  111.    Begin CommandButton cmdBtn 
  112.       Caption         =   "Show &Dialog"
  113.       Height          =   330
  114.       Index           =   1
  115.       Left            =   4800
  116.       TabIndex        =   2
  117.       Top             =   1170
  118.       Width           =   1300
  119.    End
  120.    Begin CommandButton cmdBtn 
  121.       Caption         =   "&Set Default"
  122.       Height          =   330
  123.       Index           =   0
  124.       Left            =   4800
  125.       TabIndex        =   1
  126.       Top             =   780
  127.       Width           =   1300
  128.    End
  129.    Begin ListBox lstPrinters 
  130.       Height          =   1590
  131.       Left            =   60
  132.       TabIndex        =   0
  133.       Top             =   255
  134.       Width           =   3270
  135.    End
  136.    Begin Label lblDefDriver 
  137.       BackColor       =   &H00FFFFFF&
  138.       BackStyle       =   0  'Transparent
  139.       ForeColor       =   &H00FFFFFF&
  140.       Height          =   195
  141.       Left            =   4050
  142.       TabIndex        =   10
  143.       Top             =   510
  144.       Width           =   1410
  145.    End
  146.    Begin Label Label1 
  147.       AutoSize        =   -1  'True
  148.       BackStyle       =   0  'Transparent
  149.       Caption         =   "Driver:"
  150.       Height          =   195
  151.       Index           =   2
  152.       Left            =   3420
  153.       TabIndex        =   9
  154.       Top             =   525
  155.       Width           =   585
  156.    End
  157.    Begin Label lblDefault 
  158.       BackColor       =   &H00FFFFFF&
  159.       BackStyle       =   0  'Transparent
  160.       ForeColor       =   &H00FFFFFF&
  161.       Height          =   195
  162.       Left            =   3420
  163.       TabIndex        =   8
  164.       Top             =   270
  165.       Width           =   2610
  166.    End
  167.    Begin Label Label1 
  168.       AutoSize        =   -1  'True
  169.       BackStyle       =   0  'Transparent
  170.       Caption         =   "Current default printer:"
  171.       Height          =   195
  172.       Index           =   1
  173.       Left            =   3420
  174.       TabIndex        =   7
  175.       Top             =   30
  176.       Width           =   1935
  177.    End
  178.    Begin Label Label1 
  179.       AutoSize        =   -1  'True
  180.       BackStyle       =   0  'Transparent
  181.       Caption         =   "Installed printers"
  182.       Height          =   195
  183.       Index           =   0
  184.       Left            =   60
  185.       TabIndex        =   6
  186.       Top             =   30
  187.       Width           =   1425
  188.    End
  189. End
  190. DefInt I
  191. DefLng L
  192. DefStr S
  193.  
  194. Option Explicit
  195.  
  196. Dim Shared DeviceData() As DEVMODE_TYPE
  197.  
  198. Sub cmdBtn_Click (Index As Integer)
  199.   Dim iRet As Integer
  200.   Dim inMode As DEVMODE_TYPE
  201.   Dim outMode As DEVMODE_TYPE
  202.   Dim sTemp As String
  203.   Dim iMode As Integer
  204.   Dim sTemp2 As String
  205.  
  206.   Select Case Index
  207.     Case 0
  208.       If lstPrinters.ListIndex = True Then Exit Sub
  209.       sTemp = lstPrinters.List(lstPrinters.ListIndex)
  210.       iRet = VBSetDefPrinter(sTemp)
  211.       If iRet <> True Then MsgBox "Error setting default printer", 48, "Error"
  212.       Timer1_Timer
  213.     Case 1
  214.       If lstPrinters.ListIndex = True Then Exit Sub
  215.       sTemp = lstPrinters.List(lstPrinters.ListIndex)
  216.       iMode = DM_OUT_BUFFER Or DM_IN_PROMPT
  217.       If chkPerm.Value <> 0 Then iMode = iMode Or DM_OUT_DEFAULT
  218.       If chkDefault.Value = 0 Then iMode = iMode Or DM_IN_BUFFER
  219.       sTemp2 = VBDevModeToStr(DeviceData(lstPrinters.ListIndex))
  220.       iRet = VBStrToDevMode(sTemp2, inMode)
  221.       iRet = VBExtDeviceMode(0, sTemp, inMode, DeviceData(lstPrinters.ListIndex), iMode)
  222.     Case 2
  223.       End
  224.   End Select
  225. End Sub
  226.  
  227. Sub Form_Load ()
  228.   Dim sTemp As String
  229.   Dim inMode As DEVMODE_TYPE
  230.   Dim iRet As Integer
  231.  
  232.   Me.Left = screen.Width / 2 - Me.Width / 2
  233.   Me.Top = screen.Height / 2 - Me.Height / 2
  234.   
  235.   sTemp = VBGetPrinters()
  236.   While sTemp <> ""
  237.     ReDim Preserve DeviceData(lstPrinters.ListCount)
  238.     iRet = VBExtDeviceMode(0, sTemp, inMode, DeviceData(lstPrinters.ListCount), DM_OUT_BUFFER)
  239.     If iRet = 1 Then lstPrinters.AddItem sTemp
  240.     sTemp = VBGetPrinters()
  241.   Wend
  242.   lstPrinters.ListIndex = 0
  243.   lstPrinters_Click
  244.   Timer1_Timer
  245. End Sub
  246.  
  247. Sub lstPrinters_Click ()
  248.   ShowOptions lstPrinters.List(lstPrinters.ListIndex) + ""
  249. End Sub
  250.  
  251. Sub ShowOptions (sPrinter As String)
  252.   Dim resList() As ENUMRESOLUTIONS_TYPE
  253.   Dim binNameList() As BINNAMES_TYPE
  254.   Dim binNumList() As Integer
  255.   Dim papNameList() As PAPERNAMES_TYPE
  256.   Dim papSizeList() As PAPERSIZE_TYPE
  257.   Dim lRet As Long
  258.   Dim inDev As DEVMODE_TYPE
  259.   Dim iCounter As Integer
  260.  
  261.   ' Step 1, find out how many paper sizes/names there are
  262.   lRet = VBDeviceCapabilities(sPrinter, DC_PAPERSIZE, ByVal 0&, inDev)
  263.   If lRet = 0 Then Exit Sub
  264.   
  265.   ' Size our arrays accordingly
  266.   ReDim papSizeList(lRet - 1) As PAPERSIZE_TYPE
  267.   ReDim papNameList(lRet - 1) As PAPERNAMES_TYPE
  268.   
  269.   papNameList(0).sName = "Test1